<template>
    <u-popup
        v-model="isShow"
        :closeable="true"
        mode="center"
        :maskCloseAble="false"
        border-radius="20"
    >
        <view class="px-[50rpx] py-[40rpx] bg-white" style="width: 85vw">
            <u-form label-width="120">
                    <u-form-item label="分会：" borderBottom>
                        {{ form.newGuildName }}
                    </u-form-item>
                    <u-form-item label="备注：" borderBottom>
                        <u-input v-model="form.remark" placeholder="请输入备注" type="textarea" />
                    </u-form-item>
                <view class="mt-[80rpx]">
                    <u-button class="btn-cyan" shape="circle" hover-class="none" :loading="btnLoading" @click="submitForm"> 确定 </u-button>
                </view>
            </u-form> 
        </view>
    </u-popup>
</template>
<script setup lang="ts">
import { useAppStore } from '@/stores/app';
const appStore = useAppStore();
const {proxy} = getCurrentInstance() as ComponentInternalInstance;
const emit = defineEmits(['confirm']);
const isShow = ref(false);
let form = reactive({
    userId: null,
    nickname: null,
    guildId: null,
    guildName: null,
    newGuildId: null,
    newGuildName: null,
    remark: null,
    stats: 0,
});
let btnLoading = ref(false);
const init = (row) => {
    form.newGuildId = row.guildId;
    form.newGuildName = row.guildName;
    form.userId = appStore.userInfo.userId;
    form.nickname = appStore.userInfo.nickname;
    form.guildId = appStore.guildInfo.guildId;
    form.guildName = appStore.guildInfo.guildName;
    form.remark = null;
    isShow.value = true;
};
const submitForm = () => {
    btnLoading.value = true;
    proxy.$http('post', '/admin/userNewGuilds', form, (data,msg) => {
        uni.$u.toast('提交成功');
        btnLoading.value = false;
        isShow.value = false;
        uni.reLaunch({
            url: '/packageA/branch/changeRecords'
        })
    },msg => {
        btnLoading.value = false;
    });
}
defineExpose({
  init,
})
</script>